package client;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;

import javax.swing.*;

public class DisplayError extends JFrame implements ActionListener,Serializable {

	private JLabel img;
	private JTextArea testo;
	private JButton ok;
	private ImageIcon errore=new ImageIcon("errore.jpg");
	
	public DisplayError(String s){
		
		super("DisplayError");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		JPanel pannello = new JPanel();
		pannello.setLayout(new FlowLayout());
		
		img = new JLabel(errore);
		img.setPreferredSize(new Dimension(70,70));
		ok = new JButton("OK");
		ok.setPreferredSize(new Dimension(100,70));
		ok.addActionListener(this);
		testo = new JTextArea(s + "\n");
		testo.setPreferredSize(new Dimension(300,70));
		testo.setLineWrap(true);
		testo.setWrapStyleWord(true);
		testo.setOpaque(true);
		testo.setBackground(Color.WHITE);		
		
		pannello.add(img);
		
		pannello.add(testo);
		
		pannello.add(ok);
		
		add(pannello);
		pack();
		validate();
		setVisible(true);
		
		synchronized(this){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
		
	public void actionPerformed(ActionEvent e) {
		synchronized(this){
			notifyAll();
			dispose();
			}
	}

}
